<!-- pass a variable to included page -->
<%@ page import="SSP.*" %> 
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<% 
   String today = null;
   Today t = new Today();
   today = t.getToday();
   request.setAttribute("picture","InstructorSamples");
   request.setAttribute("title", "Customer List (for internal use only)");  
   request.setAttribute("header", "Welcome : Today is " + today);
   int resultmsg = 0;
   String outputmsg = ""; 
 %>
 <%@ include file="header.jsp"%>
<TD width="850" vAlign="top"> 

<br /><h2>Customer Details</h2><br />
<table width="100%" border="0">

<%


int customerid = Integer.parseInt(request.getParameter("customerid"));
String myErrorMsgID = request.getParameter("msgid");


Customer c = new Customer();
c.setCustomerid(customerid);
c.getCustomerDetails();

String customername = c.getCustomername();
String customertypedesc = c.getCustomerTypeDesc();
String billingstreet = c.getBillingstreet();
String billingcity = c.getBillingcity();
String billingstate = c.getBillingstate();
String billingzip = c.getBillingzip();
String firstname = c.getFirstname();
String lastname = c.getLastname();
String phone = c.getPhone();
String email = c.getEmail();
String position = c.getPosition();
%>
	    


<script Language=JavaScript>
function validateCustomerUpdate() {
if (form1.customername.value == "") {  
	alert("The value for 'Customername' is empty!"); 	
	return false;   } 
if (form1.billingstreet.value == "") {  
	alert("The value for 'Billing Street' is empty!"); 	
	return false;   } 
if (form1.billingcity.value == "") {  
	alert("The value for 'Billing City' is empty!"); 	
	return false;   } 
if (form1.contactfirstname.value == "") {  
	alert("The value for 'First Name' is empty!"); 	
	return false;   } 
if (form1.contactlastname.value == "") {  
	alert("The value for 'Last Name' is empty!"); 	
	return false;   } 
if (form1.contactphone.value == "") {  
	alert("The value for 'Phone' is empty!"); 	
	return false;   } 
if (form1.contactemail.value == "") {  
	alert("The value for 'Email' is empty!"); 	
	return false;   } 
if (form1.contactposition.value == "") {  
	alert("The value for 'Position' is empty!"); 	
	return false;   }
	  		 		 		 		 	 	 	 	 
}
</script>

<form name=form1 action=customerupdate.jsp method=post onSubmit="return validateCustomerUpdate()">
    <table width="50%" border="0">        
    	<tr>
    	<td>Customer ID: </td>
    	<td><input type=text size = 10 name=customerid value=<%=customerid%> readonly></td>
    	</tr>
		<tr>
	 	<td>Customer Name: </td>
		<td><input type=text size = 50 maxlength = 45 name=customername value="<%=customername%>"></td>
		</tr> 
		<tr>
		<td>Customer Type: </td>
		<td><input type=text size = 50 name=customertypedesc value="<%=customertypedesc%>" readonly></td>
		</tr>
		<tr>
		<td>Billing Street: </td>
		<td><input type=text size=50 maxlength = 30 name=billingstreet value="<%=billingstreet%>"></td>
		</tr>
		<tr>
		<td>Billing City: </td>
		<td><input type=text size=30 maxlength = 20 name=billingcity value="<%=billingcity%>"></td>
		<td>Billing State: </td><td><input type=text size=5 maxlength = 2 name=billingstate value="<%=billingstate%>"></td>
		<td>Billing Zip: </td><td><input type=text size=8 maxlength = 5 name=billingzip value="<%=billingzip%>"></td>
		</tr>
		<tr>
		<td>Contact First Name: </td>
		<td><input type=text size=50 maxlength = 20 name=contactfirstname value="<%=firstname%>"></td>
		</tr>
		<tr><td>Contact Last Name: </td>
		<td><input type=text size=50 maxlength = 20 name=contactlastname value="<%=lastname%>"></td>
		</tr>
		<tr>
		<td>Phone Number: </td>
		<td><input type=text size=50 maxlength = 15 name=contactphone value="<%=phone%>"></td>
		</tr>
		<tr>
		<td>Email: </td>
		<td><input type=text size=50 maxlength = 50 name=contactemail value="<%=email%>"></td>
		</tr>
		<tr>
		<td>Position: </td>
		<td><input type=text size=50 maxlength = 30 name=contactposition value="<%=position%>"></td>
		</tr>
		
		<tr> <td>&nbsp;</td></tr>
		 <hr>
     <tr> <td><input name="Submit" type="submit" value="Update customer" name="submit"></td>
      </tr>
      
      <%
      
resultmsg=Integer.parseInt(myErrorMsgID);
 if (resultmsg!=0){
  if (resultmsg==1){
   outputmsg = "update succesful!";
     }else{
   outputmsg= "FAIL";
   }
 }
	 %>
	 
	 <tr>
	 <td>
	 <%=outputmsg%>
</table>
    </form>
 
</table>
rs.close();
c.closeConnection(); 
%>
</TD></TR></TABLE></body></html>